import http from '~/plugins/HTTP';

const API = {
  postRegister: '/api/v1/user', // 注册用户
  postLogin: '/api/v1/user/login', // 登录用户
  postLogout: '/api/v1/user/logout', // 用户登出
  getEmailCode: '/api/v1/user/create/authcode', // 获取邮箱验证码
  postSetScoped: '/api/v1/user/scope', // 设置用户权限
  getAllUserList: '/api/v1/user/list', // 获取所有用户列表
  postUserInformation: '/api/v1/user/update', // 更新用户资料
  getUserDetail: '/api/v1/user/detail/', // {uid} 获取用户详细信息
  postChangeCode: '/api/v1/user/password/authcode', // 修改密码时发送的验证码
  postPasswordChange: '/api/v1/user/password/update', // 修改用户密码
}

export default {
  postRegister(data) {
    return http.post(API.postRegister, data)
  },
  postLogin(data) {
    return http.post(API.postLogin, data)
  },
  postLogout() {
    return http.post(API.postLogout)
  },
  getEmailCode(data) {
    return http.post(API.getEmailCode, data)
  },
  postSetScoped(data) {
    return http.post(API.postSetScoped, data)
  },
  getAllUserList(params) {
    return http.get(API.getAllUserList, { params })
  },
  postUserInformation(data) {
    return http.post(API.postUserInformation, data)
  },
  getUserDetail(uid) {
    return http.get(API.getUserDetail + uid)
  },
  postChangeCode(data) {
    return http.post(API.postChangeCode, data)
  },
  postPasswordChange(data) {
    return http.post(API.postPasswordChange, data)
  }
}